package demo.day14

// 懒汉式单例的实现 Kotlin版本 安全
class SingletonDemoSafeKt{
    companion object{
        private var instance: SingletonDemoSafeKt? = null
            get() {
                if (field == null){
                    field = SingletonDemoSafeKt()
                }
                return field
            }
        @Synchronized
        fun getInstanceAction():SingletonDemoSafeKt = instance!!
    }

    fun show(){
        println("show函数被调用了")
    }
}

fun main() {
    SingletonDemoSafeKt.getInstanceAction().show()
}